package com.dc.system.model;

import java.io.Serializable;
import java.util.Date;

/**
 * @Description: ApprovalHistory 流程的历史，流程的进程（所有的用户操作审批的历史）
 * @Author: ChenXueLi
 * @Date: 2018-05-02 15:15
 */
public class ApprovalHistory implements Serializable {

    /**
     * 主键id
     */
    private Integer history_id;

    /**
     * 流程的编号
     */
    private Integer process_id;

    /**
     * 审批人
     */
    private String approver;

    /**
     * 审批用户
     */
    private SysUser current_approver;

    /**
     * 给定的审批状态（2未通过 1通过 0未审核）
     */
    private Integer approval_state;

    /**
     * 创建人用户id
     */
    private int create_user_id;

    /**
     * 创建人用户名
     */
    private String create_user_name;

    /**
     * 创建时间
     */
    private Date create_time;

    /**
     * 更新人用户id
     */
    private int update_user_id;

    /**
     * 更新人用户名
     */
    private String update_user_name;

    /**
     * 更新时间
     */
    private Date update_time;

    /**
     * 0删除1存在
     */
    private int is_deleted;

    /**
     * 版本号
     */
    private int version;

    public int getVersion() {
        return version;
    }

    public void setVersion(int version) {
        this.version = version;
    }

    public Integer getHistory_id() {
        return history_id;
    }

    public void setHistory_id(Integer history_id) {
        this.history_id = history_id;
    }

    public Integer getProcess_id() {
        return process_id;
    }

    public void setProcess_id(Integer process_id) {
        this.process_id = process_id;
    }

    public String getApprover() {
        return approver;
    }

    public void setApprover(String approver) {
        this.approver = approver;
    }

    public SysUser getCurrent_approver() {
        return current_approver;
    }

    public void setCurrent_approver(SysUser current_approver) {
        this.current_approver = current_approver;
    }

    public Integer getApproval_state() {
        return approval_state;
    }

    public void setApproval_state(Integer approval_state) {
        this.approval_state = approval_state;
    }

    public int getCreate_user_id() {
        return create_user_id;
    }

    public void setCreate_user_id(int create_user_id) {
        this.create_user_id = create_user_id;
    }

    public String getCreate_user_name() {
        return create_user_name;
    }

    public void setCreate_user_name(String create_user_name) {
        this.create_user_name = create_user_name;
    }

    public Date getCreate_time() {
        return create_time;
    }

    public void setCreate_time(Date create_time) {
        this.create_time = create_time;
    }

    public int getUpdate_user_id() {
        return update_user_id;
    }

    public void setUpdate_user_id(int update_user_id) {
        this.update_user_id = update_user_id;
    }

    public String getUpdate_user_name() {
        return update_user_name;
    }

    public void setUpdate_user_name(String update_user_name) {
        this.update_user_name = update_user_name;
    }

    public Date getUpdate_time() {
        return update_time;
    }

    public void setUpdate_time(Date update_time) {
        this.update_time = update_time;
    }

    public int getIs_deleted() {
        return is_deleted;
    }

    public void setIs_deleted(int is_deleted) {
        this.is_deleted = is_deleted;
    }

    public ApprovalHistory() {

    }

    public ApprovalHistory(SysUser sysUser) {
        this.create_time = new Date();
        this.create_user_id = sysUser.getUser_id();
        this.create_user_name = sysUser.getAccount();
        this.update_time = new Date();
        this.update_user_id = sysUser.getUser_id();
        this.update_user_name = sysUser.getAccount();
    }

    /**
     * 根据流程设置历史进程
     * @param approvalProcess
     * @param index
     */
    public void initHistoryByProcess(ApprovalProcess approvalProcess, Integer index) {
        this.process_id = approvalProcess.getProcess_id();
        this.approval_state = 0;
        if(index != null) {
            this.approver = approvalProcess.getApprover_list().get(index).getAccount();
        }else {
            this.approver = approvalProcess.getCurrent_approver();
        }

    }

}
